package org.jeecg.modules.flowable.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import org.apache.ibatis.annotations.Param;
import org.flowable.bpmn.model.EndEvent;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.flowable.dto.BpmnModelDTO;
import org.jeecg.modules.flowable.entity.FlowModel;
import org.jeecg.modules.flowable.query.FlowModelQuery;
import org.jeecg.modules.flowable.query.FlowTaskQuery;
import org.jeecg.modules.flowable.vo.FlowModelVO;
import org.jeecg.modules.flowable.vo.FlowTaskVO;

import java.io.InputStream;
import java.util.List;

public interface FlowModelService extends IService<FlowModel> {

    boolean save(FlowModel entity);

    /**
     * 发布流程模型，使模型生成流程
     */
    Result<Void> publish(String modelId);

    /**
     * 导入Bpmn模型，生成流程记录
     */
    Result<Void> importBpmnModel(BpmnModelDTO bpmnModel);

    /**
     * 根据模型Id加载xml内容
     */
    Result<FlowModelVO> loadBpmnXmlByModelId(String modelId);

    /**
     * 根据模型Id加载xml内容
     */
    Result<FlowModelVO> loadBpmnXmlByProcessDefinitionId(String processDefinitionId);

    /**
     * 查询结束节点
     */
    List<EndEvent> findEndFlowElement(String processDefinitionId);

    /**
     * 业务表示查询绑定的流程
     */
    FlowModel getByBusinessKey(String businessKey);

    void updateState(Integer state, String id);

    Page<FlowModelVO> getList(  @Param("query") FlowModelQuery query);

    /**
     * 生成流程图
     */
    InputStream genProcessDiagram(String processDefinitionId);

    /**
     * 生成流程实例进度图
     */
    InputStream genProcessDiagramSchedule(String processInstanceId);

    FlowModel searchByBussinessKey(String BussinessKey);

}
